<template>
    <div style="padding: 10px;">
        <el-form :model="formData" ref="queryForm" :inline="true" :rules="Rules" label-width="auto"
                 @submit.native.prevent>
            <el-form-item label="分类" desc="分类" prop="classId">
                <classSelectOne v-model="formData.classId" :text="formData.className"
                                typeInfo="generate_template"
                                placeholder="分类id" clearable
                                size="small" style="width:120px;" />
            </el-form-item>
            
            <el-form-item label="名称" desc="名称" prop="name">
                <el-input v-model.trim="formData.name" placeholder="名称" clearable size="small" style="width:120px;" />
            </el-form-item>
            <el-form-item label="文件尾缀" desc="文件尾缀" prop="name">
                <el-input v-model.trim="formData.fileSuffix" placeholder="名称" clearable size="small" style="width:120px;" />
            </el-form-item>
    
            
            <div>
                <el-form-item label="模板内容" desc="模板内容" prop="content">
                    <el-input v-model="formData.content" placeholder="模板内容" clearable size="small"
                              style="width:666px;"
                              rows="30"
                              type="textarea"
                               />
                </el-form-item>
            </div>
        
        </el-form>
    </div>
</template>
<script>  import { getUrlParam } from '@/utils/index';
import { alertWithPaylod } from '@/utils/alertUtil';
import * as  api from '@/apis/systemplate.api.js';
import { default as FormDialog } from '@codegenarate/mydialogplus';
import { fillData, validatePromise } from '@/utils/index';

const Rules = {
  'id': [{ required: false, message: '编号', trigger: 'blur' }],
  'name': [{ required: false, message: '名称', trigger: 'blur' }],
  'content': [{ required: false, message: '模板内容', trigger: 'blur' }],
  'classId': [{ required: false, message: '分类id', trigger: 'blur' }],
  'className': [{ required: false, message: '分类名称', trigger: 'blur' }],
};
const dicInner = {
  '___sys_template_id': '编号',
  'sys_template_id': 'sys_template_id',
  '___sys_template_name': '名称',
  'sys_template_name': 'sys_template_name',
  '___sys_template_content': '模板内容',
  'sys_template_content': 'sys_template_content',
  '___sys_template_classId': '分类id',
  'sys_template_classId': 'sys_template_classId',
  '___sys_template_className': '分类名称',
  'sys_template_className': 'sys_template_className',
};
export default {
  name: 'sysTemplateModify',
  data() {
    return {
      api: api,
      Rules,
      dicInner,
      formData: {
      'id': '', 'name': '', 'content': '', 'classId': '',
       'className': '',
       'fileSuffix':"",
        },
      lists: [],
      selectRows: [],
      classId: '',
      classIdPath: '',
      className: '',
      loading: false,
      isFold: false,
      tableRowClassName({ row, rowIndex }) {
        if (row.rowType == 'total') {
          return 'total-row';
        }
        return '';
      },
    };
  },
  components: {
    svgIcon: () => import('@codegenarate/svg-icon'),
    dicSelect: () => import('@/components/dicselect.vue'),
    dicTag: () => import('@/components/DicSelect/dic-tag.vue'),
    classSelectOne: () => import('@/components/classSelectOne/classSelectOne.vue'),
  },
  computed: {},
  watch: {},
  methods: {
    /**       *  @params _data.
     *          * @desc 初始化        */
    initByDialog(_data) {
      fillData(this.formData, _data);
      console.log('初始化数据', this.formData);
    }, async submitByDialog(_data) {
      var isyes = await validatePromise.call(this, 'queryForm');
      if (!isyes) {
        return { success: false, message: '请检查必填项' };
      }
      var func = this.formData.id ? api.update : api.add;
      var result = await func(this.formData);
      alertWithPaylod(result);
      return result;
    },
  },
};</script>
